﻿using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SartmenuEditor.helper;

namespace SartmenuEditor
{
    public partial class frmEdit : frmBase
    {
        private MenuEntry _mnuEntry;
        private List<string> folders = new List<string>();
        private string PATH = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);

        public MenuEntry mnuEntry
        {
            get
            {
                return _mnuEntry;
            }
            set
            {
                _mnuEntry = value;
                setTitle(_mnuEntry.Name);
            }
        }

        public frmEdit()
        {
            InitializeComponent();
            setLayout();
        }

        private void setLayout()
        {
            mnuBack.Text = Global.getString("general_back");
            mnuLeft.Enabled = false;
        }

        private void getFolders(string folder)
        {
            folders.Add(folder);
            DirectoryInfo di = new DirectoryInfo(folder);
            if(new DirectoryInfo(folder).GetDirectories().Length == 0) return;
            foreach (DirectoryInfo content in di.GetDirectories())
            {
                getFolders(content.FullName);
            }
        }

        private void frmEdit_Load(object sender, EventArgs e)
        {
            getFolders(PATH);
            cbFolders.Items.Clear();
            foreach (string folder in folders)
            {
                cbFolders.Items.Add(folder);
            }
        }

        private void mnuBack_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void cbFolders_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(!string.IsNullOrEmpty(cbFolders.Text))
            {
                mnuBack.Text = Global.getString("general_ok");
            }
            else
            {
                mnuBack.Text = Global.getString("general_back");
            }
        }


    }

    public class Folder
    {
        public string folder { get; set; }
    }
}